<?php

namespace addons\groupon\controller\store;

use addons\groupon\exception\Exception;
use addons\groupon\library\traits\export\ExportOrder;
/**
 * 门店包裹
 */
class StoreExpress extends Base
{
    use ExportOrder;
    
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];


    public function index() {
        $params = $this->request->get();

        $this->success('包裹列表', \addons\groupon\model\store\StoreExpress::getList($params));
    }


    public function detail() {
        $params = $this->request->get();

        $this->success('包裹详情', \addons\groupon\model\store\StoreExpress::getDetail($params));
    }


    /**
     * 包裹到货
     *
     * @return void
     */
    public function arrive()
    {
        $params = $this->request->post();
        $this->success('到货成功', \addons\groupon\model\store\StoreExpress::operArrive($params));
    }


    public function export() {
        $params = $this->request->get();
        $id = $params['id'] ?? 0;

        $orderStoreExpress = \app\admin\model\groupon\order\OrderStoreExpress::with(['store'])->where('id', $id)->find();

        if (!$orderStoreExpress) {
            $this->error('包裹未找到');
        }

        $this->exportOutput($orderStoreExpress);
    }
}
